#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main()
{
	int n = 0;
	scanf("%d",&n);
	switch (n % 3)
	{
	case 0:
		printf("0"); break;
	case 1:
		printf("1"); break;
	case 2:
		printf("2");break;
		
	}
	return 0;
}